package com.springboot.frame;

import feign.RequestLine;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liheng
 * @ClassName FeignApplication
 * @Description
 * @date 2021-03-23 16:28
 */
@SpringBootApplication
@EnableFeignClients
public class FeignApplication {
    public static void main(String[] args) {
        SpringApplication.run(FeignApplication.class, args);
    }

    @RestController
    static class IndexController {
        @Autowired
        private AccountFeign accountFeign;
        @GetMapping("/get_demo")
        public String getDemo() {
            return ">>>>>>>>>>>21211====";
        }

        @GetMapping("/echo")
        public String echo() {
            return accountFeign.echo();
        }
    }


    @Component
    @FeignClient(name = "spring-cloud-nacos-discovery")
    interface AccountFeign {
        @GetMapping("/echo")
        String echo();

        @RequestLine("GET /123")
        String line();
    }
}
